<?php

class Task extends CI_Controller{
    function __construct() {
        parent::__construct();
        $this->load->model('chapter_m');
        $this->load->model('task_m');
        $this->load->model('tm_m');
    }

//    function getlist($subjectid){
//        $this->load->helper('utils');
//        $chapters=$this->chapter_m->getlist($subjectid);        
//        if($chapters){
//            $stdobj=new stdClass();
//            $stdobj->chapter=array_urlencode($chapters);
//            foreach($chapters as $key=>$val){
//                $tasks=$this->task_m->getlist($val->id);
//                if($tasks){
//                   $stdobj->chapter[$key]->task=array_urlencode($tasks);
//                }
//            }
//        }
//        echo urldecode(json_encode(obj_urlencode($stdobj)));
//    }
    
    function getexecs($id){
        $tbs=array('singlechoice','multichoice','judge');
        $data=array();
        foreach ($tbs as $t) {
            $list=$this->tm_m->getlist($t,$id);       
            if($list){
            //echo json_encode($subjects[0]);
                foreach ($list as $s){
                    foreach($s as $key=>$val){
                        $s->$key =  urlencode($val);
                    }
                }
                $data[$t]=json_encode($list);
            }
        }
        $result=array('code'=>'success','msg'=>'','data'=>$data);
		header("Content-Type:text/html;charset=utf8");
        echo urldecode(json_encode($result));
    }
}

